home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / incl / LEDA / impl / ch_array.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  1.9 KB  |  94 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  ch_array.h
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef LEDA_CH_HASHING3_H
  16. #define LEDA_CH_HASHING3_H
  17.  
  18. //------------------------------------------------------------------------------
  19. // Hashing Array with Chaining
  20. //
  21. // S. Naeher  (1994)
  22. //
  23. //------------------------------------------------------------------------------
  24.  
  25. #include <LEDA/basic.h>
  26.  
  27.  
  28. //------------------------------------------------------------------------------
  29. // class ch_array_elem  
  30. //------------------------------------------------------------------------------
  31.  
  32. class ch_array_elem 
  33. {
  34.   friend class ch_array;
  35.  
  36.   ch_array_elem* succ;
  37.   GenPtr k;
  38.   GenPtr i;
  39.  
  40. };
  41.  
  42. typedef ch_array_elem*  ch_array_item;
  43.  
  44.  
  45. //--------------------------------------------------------------------
  46. // class ch_array
  47. //--------------------------------------------------------------------
  48.  
  49.  
  50. class ch_array 
  51. {
  52.  
  53.    static ch_array_elem STOP;
  54.  
  55.    ch_array_elem* table;
  56.    ch_array_elem* table_end;
  57.    ch_array_elem* free;
  58.    int table_size;           
  59.    int table_size_1;           
  60.    int shift;
  61.  
  62.    GenPtr  init_val;
  63.  
  64.    virtual void clear_inf(GenPtr&)  const { }
  65.    virtual void copy_inf(GenPtr&)   const { }
  66.  
  67.    void init_table(int);
  68.    void rehash();
  69.    void destroy();
  70.  
  71.  
  72.    public:
  73.  
  74.    GenPtr& access(GenPtr);
  75.    GenPtr  access(GenPtr) const;
  76.    GenPtr  lookup(GenPtr) const;
  77.  
  78.    void print();
  79.  
  80.    ch_array_item first_item() const { return 0; }
  81.    ch_array_item next_item(ch_array_item) const { return 0; }
  82.  
  83.    ch_array& operator=(const ch_array&);
  84.    ch_array(const ch_array&);
  85.    ch_array(GenPtr ini=0, int sz = 0, int n=1024); 
  86.  
  87.    virtual ~ch_array() { destroy(); }
  88.  
  89. };
  90.  
  91.  
  92. #endif
  93.